package com.day21me.java;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.util.Scanner;

//演示socket通讯单次的双向传递对象
public class Test3 {
    public static void main(String[] args) {
        try{
            Socket socket =new Socket("localhost",888);
            Test3User user = new Test3User();
            Scanner input =new Scanner(System.in);
            System.out.println("请输入用户名");
            user.setLoginName(input.next());
            System.out.println("请输入密码");
            user.setLoginPwd(input.next());
            user.setUserID(1);
            ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
            oos.writeObject(oos);
            oos.flush();
            socket.shutdownOutput();
            BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            String answer =br.readLine();




            user.setUserID(1);




        }catch (Exception ex){
            ex.printStackTrace();
        }
    }
}
